{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 \n",
    "\n",
    "示例：\n",
    "\n",
    "输入：1->2->4, 1->3->4\n",
    "输出：1->1->2->3->4->4\n",
    "\n",
    "\n",
    "来源：力扣（LeetCode）\n",
    "链接：https://leetcode-cn.com/problems/merge-two-sorted-lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n"
     ]
    }
   ],
   "source": [
    "# Definition for singly-linked list\n",
    "class ListNode(object):\n",
    "    def __init__(self, x):\n",
    "        self.val = x\n",
    "        self.next = None\n",
    "    \n",
    "class Solution(object):\n",
    "    def mergeTwoLists(self, l1, l2):\n",
    "        \"\"\"\n",
    "        :type l1: ListNode\n",
    "        :type l2: ListNode\n",
    "        :rtype: ListNode\n",
    "        \"\"\"\n",
    "        if l1 is null:\n",
    "            return l2\n",
    "        elif l2 is null:\n",
    "            return l1\n",
    "        elif l1.val < l2.val:\n",
    "            l1.next = self.mergeTwoLists(l1.next, l2)\n",
    "            return l1\n",
    "        else:\n",
    "            l2.next = self.mergeTwoLists(l1, l2.next)\n",
    "            return l2\n",
    "    \n",
    "if __name__ == \"__main__\":\n",
    "    pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
